package net.zjitc.dao;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.jdbc.core.JdbcTemplate;

public class SingletonJdbcTemplate {
    private static JdbcTemplate jdbcTemplate=null;
    public static JdbcTemplate getJdbcTemplate(){

        if (jdbcTemplate==null){
            DruidDataSource druidDataSource=new DruidDataSource();
            druidDataSource.setDriverClassName("com.mysql.jdbc.Driver");
            druidDataSource.setUrl("jdbc:mysql://127.0.0.1:3306");
            druidDataSource.setUsername("root");
            druidDataSource.setPassword("root");

            jdbcTemplate=new JdbcTemplate(druidDataSource);
        }

        return jdbcTemplate;

    }
}
